package pong;

public class Vector2 {

	private float x, y;

	public Vector2(final float x, final float y) {
		super();
		this.x = x;
		this.y = y;
	}

	public float getX() {
		return x;
	}

	public void setX(final float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(final float y) {
		this.y = y;
	}

	public void move(final float deltaX, final float deltaY) {
		this.x += deltaX;
		this.y += deltaY;
	}

	public Vector2 add(final Vector2 toBeAdded) {
		return new Vector2(this.x + toBeAdded.x, this.y + toBeAdded.y);
	}

	public void normalize() {
		final double faktor = Math.sqrt(this.x * this.x + this.y * this.y);
		this.x /= faktor;
		this.y /= faktor;
	}

	public Vector2 mult(final float scalar) {
		return new Vector2(this.x * scalar, this.y * scalar);
	}
}
